package com.woniuxy.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.woniuxy.dao.McarParkingMapper;
import com.woniuxy.dao.TPerCommentMapper;
import com.woniuxy.dto.DataGridView;
import com.woniuxy.feign.Feigntest;
import com.woniuxy.pojo.McarParking;
import com.woniuxy.pojo.MerchantUsers;
import com.woniuxy.pojo.OverOrder;
import com.woniuxy.pojo.TPerComment;
import com.woniuxy.service.TPerCommentservice;
import com.woniuxy.service.UserService;
import com.woniuxy.vo.TPerCommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TPerCommentserviceImpl implements TPerCommentservice {
    @Autowired
    private TPerCommentMapper tPerCommentMapper;
    @Autowired
    private UserService userService;
    @Autowired
    private McarParkingMapper mcarParkingMapper;
    @Autowired
    private Feigntest feigntest;
    @Override
    public DataGridView findAllcoments(TPerCommentVo tPerCommentVo) {
        MerchantUsers merchantUsers=userService.findPuserByid(new Integer(tPerCommentVo.getMerchantID()));
        tPerCommentVo.setMerchantID(merchantUsers.getId()+"");
        PageHelper pageHelper=new PageHelper();
        Page<TPerComment> page= PageHelper.startPage(tPerCommentVo.getPage(),tPerCommentVo.getLimit());
        List<TPerComment> comments = tPerCommentMapper.findAllcoments(tPerCommentVo);
        return new DataGridView(page.getTotal(),comments);
    }

    @Override
    public String test() {

        return feigntest.test();
    }
}
